// 题意：求课重叠出现至少k词最长重复子串
//
// 题解：二分长度，按长度将高度数组分组，统计每组中超过长度的个数，
// 如果大于等于k则可以满足。
//
//
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

struct suffix_array
{
	typedef std::vector<int> & v_ref;
	typedef std::vector<int> const & v_cref;

	struct suffix_cmp
	{
		suffix_cmp(v_cref rank, int const & gap, int const & len)
			: rank(rank), gap(gap), len(len) {}

		bool operator()(int i, int j)
		{
			if (rank[i] != rank[j]) return rank[i] < rank[j];
			return (i + gap < len && j + gap < len) ?
				(rank[i + gap] < rank[j + gap]) : i > j;
		}

	private:
		v_cref rank;
		int const & gap;
		int const & len;
	};

	suffix_array(v_cref s, v_ref sa, v_ref rank, v_ref height)
		: s(s), sa(sa), rank(rank), height(height)
	{
		tmp_rank.resize(s.size());
	}

	void init_suffix_array()
	{
		int n = s.size();
		for (int i = 0; i < n; i++) { sa[i] = i; rank[i] = s[i]; }
		for (int gap = 1; ; gap *= 2) {
			suffix_cmp cmp(rank, gap, n);
			std::sort(sa.begin(), sa.begin() + n, cmp);
			for (int i = 0; i < n - 1; i++)
				tmp_rank[i + 1] = tmp_rank[i] + cmp(sa[i], sa[i + 1]);
			for (int i = 0; i < n; i++) rank[sa[i]] = tmp_rank[i];
			if (tmp_rank[n - 1] == n - 1) break;
		}
	}

	void init_lcp()
	{
		int n = s.size();
		for (int i = 0, k = 0; i < n; i++)
			if (rank[i] != n-1) {
				for (int j = sa[rank[i] + 1]; s[i + k] == s[j + k]; k++);
				height[rank[i]] = k;
				if (k) k--;
			}
	}

private:
	v_cref s;
	v_ref sa;
	v_ref rank;
	v_ref height;
	std::vector<int> tmp_rank;
};


int n, k;
std::vector<int> da;
std::vector<int> sa;
std::vector<int> rank;
std::vector<int> height;

bool judge(int l)
{
	int tot = 0;
	for (int i = 0; i < n-1; i++) {
		if (height[i] >= l) tot++;
		else {
			if (tot + 1 >= k) return true;
			tot = 0;
		}
	}
	return tot + 1 >= k;
}

int main()
{
	std::scanf("%d%d", &n, &k);
	da.resize(n);
	for (int i = 0; i < n; i++) std::scanf("%d", &da[i]);
	sa.resize(da.size());
	rank.resize(da.size());
	height.resize(da.size());

	suffix_array suffix(da, sa, rank, height);
	suffix.init_suffix_array();
	suffix.init_lcp();

	int l = 0, r = n - k + 1;
	while (l + 1 < r) {
		int mid = (l + r) / 2;
		if (judge(mid)) l = mid;
		else			r = mid - 1;
	}
	if (judge(r)) l = r;
	std::printf("%d\n", l);
}

